package com.szh.zx.gaoDingJavaBook.chapter7.two;

import java.io.*;

public class SerialuzableTest {
	public static void main(String[] args) throws IOException, ClassNotFoundException {
		Wolf wolf = new Wolf("灰太狼");
		System.out.println("对象创建完成");
		Wolf wolf1 = null;
		ObjectOutputStream oos = null;
		ObjectInputStream ois= null;
//		创建对象输出流
		oos = new ObjectOutputStream(new FileOutputStream("a.bin"));
//		创建对象输入流
		ois = new ObjectInputStream(new FileInputStream("a.bin"));
//		反序列化输出java对象
		oos.writeObject(wolf);
		oos.flush();
//		反序列化恢复java对象
		wolf1 = (Wolf) ois.readObject();
//		两个对象的实例变量值完全相等
		System.out.println(wolf.equals(wolf1));
//		两个对象不相同，下面输出false
		System.out.println(wolf=wolf1);
	}
}
